package com.tfjybj.itoo.teach.provider.facade;


import org.apache.dubbo.config.annotation.Service;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.teach.FacadeApi.CourseApi;
import com.tfjybj.itoo.teach.entity.CourseEntity;
import com.tfjybj.itoo.teach.provider.service.CourseService;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 吕德彪
 * @ClassName CourseFacade
 * @DESCRIPTION TODO
 * @create 2019/5/21
 */
@Service
@org.springframework.stereotype.Service
public class CourseFacade  implements CourseApi {
    @Resource
    CourseService courseService;

//    @Resource
//    CourseController courseController;

    /**
     * 添加
     *
     * @param courseEntity
     * @return 添加的结果
     * @author 杨江涛
     * @since 2.0.0 2018-11-24 15:14:12
     */
    @Override
    public boolean create(@RequestBody CourseEntity courseEntity) {
        return courseService.save(courseEntity);
    }

    /**
     * 删除
     *
     * @param id 主键id
     * @return ItooResult 是否删除成功
     * @author 杨江涛
     * @since 2.0.0 2018-11-24 15:14:12
     */
    @Override
    public boolean removeById(String id) {
        return courseService.removeById(id);
    }

    /**
     * 批量删除
     *
     * @param ids ids
     * @return ItooResult 批量删除是否成功结果
     * @author 杨江涛
     * @since 2.0.0 2018-11-24 15:14:12
     */
    @Override
    public boolean removeByIds(@RequestBody List<String> ids) {
        return courseService.removeByIds(ids);
    }

    /**
     * 修改
     *
     * @param courseEntity CourseEntity
     * @return 修改后的结果
     * @author 杨江涛
     * @since 2.0.0 2018-11-24 15:14:12
     */
    @Override
    public boolean updateById(@RequestBody CourseEntity courseEntity) {
        return courseService.updateById(courseEntity);
    }

    /**
     * 根据id查找Course表
     *
     * @param id 主键id
     * @return 课程信息
     * @author 杨江涛
     * @since 2.0.0  2018-11-23 20:42:04
     */
    @Override
    public CourseEntity getById(String id) {
        return courseService.getById(id);
    }

    /**
     * 分页查询所有Course
     *
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @author 张家豪
     * @since 2.0.0 2018-11-08 19:34:10
     */
    @Override
    public PageInfo<CourseEntity> queryPageAll(@ApiParam(name = "pageNo", value = "页码", required = true, example = "1") @PathVariable Integer pageNo,
                                               @ApiParam(name = "pageSize", value = "页数", required = true, example = "10") @PathVariable Integer pageSize) {
        return courseService.queryPageAll(pageNo, pageSize);
    }


    /**
     * 根据课程id查询课程名称
     *
     * @return Course表当前学年课程信息
     * @author 杨江涛
     * @since 2.0.0 2018-11-24 15:14:12
     */
    @Override
    public CourseEntity findCourse(String id){
        return courseService.findCourse(id);
    }


    /**
     * 根据参数模糊查询课程名称
     * @param searchInfo 模糊查询条件（课程名称/课程代码）
     * @return
     */
    @Override
    public PageInfo<CourseEntity> getCourse(
            @ApiParam(value = "房屋查询参数", required = true) @PathVariable String searchInfo,
            @ApiParam(name = "pageNo", value = "页码", required = true, example = "1") @PathVariable Integer pageNo,
            @ApiParam(name = "pageSize", value = "页数", required = true, example = "10") @PathVariable Integer pageSize) {
        return courseService.getCourse(searchInfo,pageNo,pageSize);
    }
//    public List<CourseEntity> getCourse(String searchInfo) {
//        return  courseService.getCourse(searchInfo);
//    }

    /**
     * 创建考试查询课程,无参查询
     * @param semester
     * @param userId userId
     * @return
     */
    @Override
    public List<CourseEntity> inquiryCourse(String semester, String userId) {
        return courseService.inquiryCourse(semester,userId);
    }

    /**
     * 课程练习-查询所有属于课程练习的课程
     * @return
     */
    @Override
    public List<CourseEntity> queryCourseAll() {
        return courseService.queryCourseAll();
    }


}
